/**
 * Copyright (C) 2021-2022 maminjie <canpool@163.com>
 * SPDX-License-Identifier: LGPL-2.1
 * Powered by Qt-Advanced-Docking-System
**/

#pragma once

#include "qads_global.h"
#include "dockmanager.h"

#include <QObject>

QADS_BEGIN_NAMESPACE

class DockFocusControllerPrivate;
class DockManager;
class DockFloatingWidget;
class DockWidget;
class DockTab;

/**
 * Manages focus styling of dock widgets and handling of focus changes
 */
class QADS_EXPORT DockFocusController : public QObject
{
    Q_OBJECT
public:
    DockFocusController(DockManager *dockManager);
    ~DockFocusController() override;

    void setWidgetFocus(QWidget *widget);
    void setDockTabFocused(DockTab *tab);
    void setDockWidgetFocused(DockWidget *focusedNow);
    DockWidget* focusedDockWidget() const;

    void notifyWidgetOrPannelRelocation(QWidget *relocatedWidget);
    void notifyFloatingWidgetDrop(DockFloatingWidget *floatingWidget);

private Q_SLOTS:
    void onApplicationFocusChanged(QWidget *old, QWidget *now);
    void onFocusWindowChanged(QWindow *focusWindow);
    void onFocusedDockPannelViewToggled(bool open);
    void onStateRestored();
    void onDockWidgetVisibilityChanged(bool Visible);

private:
    DockFocusControllerPrivate* d;
    friend class DockFocusControllerPrivate;
}; // class DockFocusController

QADS_END_NAMESPACE
